﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %>
<%@ Import Namespace="System.Collections.Generic" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	选择公司
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

    <div>
    <form method="post" target="_blank" action="<%=Url.Content("~/Modification/EditData") %>">
        请选择公司：<%= Html.DropDownList("FactoryId", ViewData["factories"] as List<SelectListItem>, "请选择公司", new { style = "width:150px", onchange="showStacks();" })%>
        <span style="margin-left:20px"></span>
        请选择堆场/尾矿库：<span id="stackList"><select id="stackId" name="stackId" style="width:150px"><option>请选择</option></select></span>
        <span style="margin-left:20px"></span>
        请选择日期：<input type="text" name="date" id="date" readonly="readonly" />
        <span style="margin-left:20px"></span>
        <input type="submit" onclick="return validForm();" value="确  定" />
    </form>
    </div>

    <script type="text/javascript" language="javascript">
        $('#date').datepicker();

        function showStacks() {
            var factoryId = document.getElementById("FactoryId").value;
            if (factoryId == "" || factoryId == 0) return;
            $.ajax({ 
                    type: "POST",
                    url: "<%=Url.Content("~/Modification/ListStacks") %>",
                    data: "factoryId=" + factoryId,
                    success: function (data) { $("#stackList").html(data);}
            });
        }

        function validForm() {
            var factoryId = document.getElementById("FactoryId").value;
            if (factoryId == 0 || factoryId == "" || factoryId == undefined) {
                alert("请选择公司！");
                document.getElementById("FactoryId").focus();
                return false;
            }

            var stackId = document.getElementById("stackId").value;
            if (stackId == 0 || stackId == "" || stackId == undefined) {
                alert("请选择堆场/尾矿库！");
                document.getElementById("stackId").focus();
                return false;
            }

            var date = document.getElementById("date").value;
            if (date == 0 || date == "" || date == undefined) {
                alert("请选择日期！");
                document.getElementById("date").focus();
                return false;
            }

            return true;
        }
    </script>
</asp:Content>
